<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="utf-8">
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>找回密码 - 空明物联网服务平台</title>
  <link rel="stylesheet" href="/static/css/bootstrap.min.css" />
  <link rel="stylesheet" href="/static/css/main.css?version=1.0.0" />
</head>
<body>
  <div class="wrapper" id="page_index">
    <h1><span class="title">空明物联网服务平台</span></h1>
    <div class="sidebar">
      <ul id="menu" class="menu">
        <li class="selected"><a href="login.html">登录</a></li>
        <li><a href="reg.html">注册</a></li>
      </ul>
    </div>
  </div>
  <div class="main-content">
    <div class="container-fluid">
      <br />
      <h2>找回密码</h2>
      <hr>
      <p id="info" style="color: #FF0000;"></p>
      <br>
      <p>邮箱账号：
        <input  type="text" id="email" name="email" required />
      </p>
      验证码：
      <input type="text" id="validate" name="validate" required /><img src="" id="ruaptcha" height="29px"
        alt="点击刷新验证码" />
      <br />
      <br />
      <br />
      <button id="btn-pwd" class="btn btn-primary btn-sm" type="submit">发送重置邮件</button>
      <button class="btn btn-default btn-sm" onClick="javascript:history.go(-1);">返回</button>
    </div>
  </div>
  <script src="/static/js/jquery-2.1.4.min.js"></script>
  <script src="/static/js/base.js?version=1.0.0"></script>
  <script>

    var t; // 待提交验证码标识

    // 刷新验证码图片
    function flushRuaptcha() {
      var timestamp = (new Date()).valueOf();
      t = timestamp
      $("#ruaptcha").attr("src", getServiceURL("getruaptcha") + "?t=" + timestamp)
    }

    $(document).ready(function () {
      flushRuaptcha();
    });


    $("#ruaptcha").click(function () {
      flushRuaptcha();
    });


    $("#btn-pwd").click(function () {
      var email = $("#email").val();
      var validate = $("#validate").val();


      if (email == "") {
        return alert("请输入电子邮箱账号！");
      }

      if (validate == "") {
        return alert("请输入验证码！");
      }


      $.ajax({
        url: getServiceURL("retrievepassword"),
        data: {
          "email": email,
          "t": t,
          "validate": validate,
        },
        type: "post",
        async: false,
        success: function (res) {
          if (res.code == 0) {
            alert("重置邮件已发送,我们已将密码重置邮件发送至您的邮箱，请在24小时内重置密码。如果您在几分钟内仍未收到邮件，请检查您的垃圾邮件，或重新发送。");
          } else {
            alert(res.msg);
          }
        }
      });
      return false;
    });
  </script>
</body>

</html>